# Tanım: SDDM paketi, Qt ve QML'de yazılmış hafif bir ekran yöneticisi içerir.
# URL: https://www.kde.org/
# Paketçi: alihan-ozturk28@hotmail.com
# Gerekler: cmake kf5-extra-cmake-modules qt5 upower consolekit2 xorg-libxkbfile libxcb
# Grup: masaüstü

isim=sddm
devir=1
surum=0.14.0

kaynak=( https://github.com/sddm/sddm/releases/download/v$surum/${isim}-$surum.tar.xz
         sddm.conf
         10-backlight.rules
         sddm-0.14.0-consolekit.patch
         ecb903e4.patch)

derle() {
wget http://anduin.linuxfromscratch.org/BLFS/blfs-bootscripts/blfs-bootscripts-20160902.tar.xz
tar xvf blfs-bootscripts-20160902.tar.xz

cd ${isim}-$surum
sed -e '/UPOWER_SERVICE)/ s:^://:' \
    -i src/daemon/PowerManager.cpp
mkdir build
patch -p1 -i ../sddm-0.14.0-consolekit.patch
patch -p1 -i ../ecb903e4.patch
cd    build
cmake -DCMAKE_INSTALL_PREFIX=/usr \
      -DCMAKE_BUILD_TYPE=Release  \
      -DENABLE_JOURNALD=OFF       \
      -DDBUS_CONFIG_FILENAME=sddm_org.freedesktop.DisplayManager.conf \
      -Wno-dev ..
make
make DESTDIR=$PKG install

install -m 644 -p $SRC/sddm.conf $PKG/etc/
mkdir -p $PKG/etc/polkit-1/
mkdir -p $PKG/etc/polkit-1/rules.d
install -m 644 -p $SRC/10-backlight.rules $PKG/etc/polkit-1/rules.d/
install -v -dm755 -o sddm -g sddm /var/lib/sddm

cat > $PKG/etc/pam.d/sddm << "EOF"
# Begin /etc/pam.d/sddm

auth     requisite      pam_nologin.so
auth     required       pam_env.so

auth     required       pam_succeed_if.so uid >= 0 quiet
#auth    sufficient     pam_succeed_if.so user ingroup nopasswdlogin
auth     include        system-auth

account  include        system-account
password include        system-password

session  required       pam_limits.so
session  include        system-session

# End /etc/pam.d/sddm
EOF

cat > $PKG/etc/pam.d/sddm-autologin << "EOF"
# Begin /etc/pam.d/sddm-autologin

auth     requisite      pam_nologin.so
auth     required       pam_env.so

auth     required       pam_succeed_if.so uid >= 0 quiet
#auth    sufficient     pam_succeed_if.so user ingroup nopasswdlogin
auth     required       pam_permit.so

account  include        system-account

password required       pam_deny.so

session  required       pam_limits.so
session  include        system-session

# End /etc/pam.d/sddm-autologin
EOF

cat > $PKG/etc/pam.d/sddm-greeter << "EOF"
# Begin /etc/pam.d/sddm-greeter

auth     required       pam_env.so
auth     required       pam_permit.so

account  required       pam_permit.so
password required       pam_deny.so
session  required       pam_unix.so
-session optional       pam_systemd.so

# End /etc/pam.d/sddm-greeter
EOF
# service
cd $SRC/blfs-bootscripts-20160902
make DESTDIR=$PKG install-sddm
}
